package puyu.manage.service.utils;


import lombok.extern.log4j.Log4j2;

import java.util.*;

@Log4j2
public class MapTranformsUtils {

    public static Map<String, Object> toLowerKey(Map<String, Object> map) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        Set<String> sets = map.keySet();
        for (String key : sets) {
            resultMap.put(key.toLowerCase(), map.get(key));
        }
        return resultMap;
    }


    public static Map<String, Object> toUpperKey(Map<String, Object> map) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        Set<String> sets = map.keySet();
        for (String key : sets) {
            resultMap.put(key.toUpperCase(), map.get(key));
        }
        return resultMap;
    }

    public static List<Map<String, Object>> transLowList(List<Map<String, Object>> list) {
        List<Map<String, Object>> newList = new ArrayList<>();
        for (Map<String, Object> map : list) {
            Map<String, Object> resultMap = new HashMap<>();
            Set<String> keySet = map.keySet();
            for (String key : keySet) {
                String newKey = key.toLowerCase();
//                newKey = newKey.replace("_", "");//去掉下划线
                resultMap.put(newKey, map.get(key));
            }
            newList.add(resultMap);
        }
        return newList;
    }
}
